#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <iostream>

int main(int argc, char *argv[])
{
    if (argc != 2)
    {
        perror("输入参数错误！");
        exit(-1);
    }
    int fd = open(argv[1], O_RDONLY);
    if(fd == -1)
    {
        perror("文件打开错误！");
        exit(-1);
    }
    char buffer[1024];
    while(true)
    {
        ssize_t ret = read(fd, buffer, sizeof(buffer) - 1);
        if(ret == -1)
        {
            perror("读取错误！");
            exit(-1);
        }
        if(ret == 0) break;
        buffer[ret] = 0;
        std::cout << buffer;
        
    }
    std::cout << std::endl;
    return 0;
}